//
//  Find_ActivityTableViewCell.m
//  SoundPill
//
//  Created by 宋旭东 on 15/6/10.
//  Copyright (c) 2015年 宋旭东. All rights reserved.
//

#import "Find_ActivityTableViewCell.h"
#import "UIViewExt.h"

@interface Find_ActivityTableViewCell ()
@end

@implementation Find_ActivityTableViewCell

-(instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        self.backgroundColor = [UIColor colorWithRed:0.965 green:0.965 blue:0.965 alpha:1.00];
        [self createSubviews];
    }
    return self;
}
- (void)createSubviews
{
    self.leftButton = [[Find_ActivityTableViewCellButton alloc] initWithFrame:CGRectMake(10, 0, (self.bounds.size.width - 30) / 2, self.bounds.size.height - 10)];
    [_leftButton addTarget:self action:@selector(leftButtonClick:) forControlEvents:UIControlEventTouchUpInside];
    [self addSubview:_leftButton];
    
    self.rightButton = [[Find_ActivityTableViewCellButton alloc] initWithFrame:CGRectMake(_leftButton.right + 10, 0, (self.bounds.size.width - 30) / 2, self.bounds.size.height - 10)];
     [_rightButton addTarget:self action:@selector(rightButtonClick:) forControlEvents:UIControlEventTouchUpInside];
    [self addSubview:_rightButton];
    
//    self.view = [[UIView alloc] initWithFrame:CGRectZero];
//    _view.layer.borderColor = [[UIColor colorWithRed:0.895 green:0.898 blue:0.908 alpha:1.000] CGColor];
//    _view.layer.borderWidth = 1;
//    _view.backgroundColor = [UIColor clearColor];
//    [self addSubview:_view];
//    
//    self.bigImage = [[UIImageView alloc] initWithFrame:CGRectZero];
//    [_bigImage setContentScaleFactor:[[UIScreen mainScreen] scale]];
//    _bigImage.contentMode = UIViewContentModeScaleAspectFill;
//    _bigImage.autoresizingMask = UIViewAutoresizingFlexibleHeight;
//    _bigImage.clipsToBounds = YES;
////    _bigImage.backgroundColor = [UIColor orangeColor];
//    [self addSubview:_bigImage];
//    
//    self.bigImgView = [[UIView alloc] initWithFrame:CGRectZero];
//    _bigImgView.backgroundColor = [UIColor blackColor];
//    _bigImgView.alpha = 0.3;
//    [self addSubview:_bigImgView];
//    
//    self.workName = [[UILabel alloc] initWithFrame:CGRectZero];
//    _workName.backgroundColor = [UIColor clearColor];
//    [self addSubview:_workName];
//    
//    self.workCreateTime = [[UILabel alloc] initWithFrame:CGRectZero];
//    [self addSubview:_workCreateTime];
//    
//    self.imageProgress = [[DACircularProgressView alloc] initWithFrame:CGRectZero];
//    _imageProgress.trackTintColor = [UIColor whiteColor];
//    _imageProgress.progressTintColor = [UIColor blackColor];
//    _imageProgress.roundedCorners = 0;
//    [self addSubview:_imageProgress];
//    
//    self.price = [[UILabel alloc] initWithFrame:CGRectZero];
//    _price.layer.borderColor = [[UIColor whiteColor] CGColor];
//    _price.layer.borderWidth = 2;
//    _price.textColor = [UIColor whiteColor];
////    _price.adjustsFontSizeToFitWidth = YES;
//    _price.textAlignment = NSTextAlignmentCenter;
//    if ([UIScreen mainScreen].bounds.size.width > 375) {
//        _price.font = [UIFont boldSystemFontOfSize:18];
//    } else {
//        _price.font = [UIFont boldSystemFontOfSize:14];
//    }
//    _price.backgroundColor = [UIColor clearColor];
//    [self addSubview:_price];
//    
//    self.playImg = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"play_gray_btn"]];
//    [self addSubview:_playImg];
//    self.playLab = [[UILabel alloc] initWithFrame:CGRectZero];
//    _playLab.font = [UIFont systemFontOfSize:14];
//    [self addSubview:_playLab];
//    self.loveImg = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"love_gray_btn"]];
//    [self addSubview:_loveImg];
//    self.loveLab = [[UILabel alloc] initWithFrame:CGRectZero];
//    _loveLab.font = [UIFont systemFontOfSize:14];
//    [self addSubview:_loveLab];
//    self.typeLable = [[UILabel alloc] initWithFrame:CGRectZero];
//    _typeLable.font = [UIFont boldSystemFontOfSize:13];
//    _typeLable.textColor = [UIColor grayColor];
//    _typeLable.textAlignment = NSTextAlignmentRight;
//    [self addSubview:_typeLable];
    
}
- (void)layoutSubviews
{
    [super layoutSubviews];
    _leftButton.frame = CGRectMake(10, 0, (self.bounds.size.width - 30) / 2, self.bounds.size.height - 10);
    _rightButton.frame = CGRectMake(_leftButton.right + 10, 0, (self.bounds.size.width - 30) / 2, self.bounds.size.height - 10);
//    _bigImage.frame = CGRectMake(10, 20, self.height - 20, self.height - 20);
//    _bigImgView.frame = CGRectMake(_bigImage.left, _bigImage.top, _bigImage.width, _bigImage.height);
//    _imageProgress.frame = CGRectMake(_bigImage.width / 2 -20, _bigImage.height / 2 - 20, 40, 40);
//    
//    _workName.numberOfLines = 0;
//    _workName.lineBreakMode = NSLineBreakByWordWrapping || NSLineBreakByCharWrapping;
//    if ([UIScreen mainScreen].bounds.size.width == 320) {
//        _workName.font = [UIFont systemFontOfSize:17];
//    } else {
//        _workName.font = [UIFont boldSystemFontOfSize:19];
//    }
//    _workName.textColor = [UIColor blackColor];
//    _workName.textAlignment = NSTextAlignmentLeft;
//    CGSize size = [self changeWorkNameFrame:_workName.text size:CGSizeMake(self.width - _bigImage.width - 40, self.frame.size.height-40) font:_workName.font];
//    _workName.frame = CGRectMake(_bigImage.right + 10, _bigImage.top + 5, size.width, size.height);
////    _workName.backgroundColor = [UIColor redColor];
////    _workName.center = CGPointMake(_workName.center.x, self.frame.size.height / 2);
//    if ([UIScreen mainScreen].bounds.size.width == 320) {
//        _workCreateTime.font = [UIFont systemFontOfSize:16];
//    } else {
//        _workCreateTime.font = [UIFont systemFontOfSize:18];
//    }
//    CGSize timeSize = [self changeWorkNameFrame:_workCreateTime.text size:CGSizeMake(_bigImage.frame.size.width, _bigImage.frame.size.width * 0.2) font:_workCreateTime.font];
//    _workCreateTime.frame = CGRectMake(_bigImage.left + 5, _bigImage.bottom - timeSize.height-5, _bigImage.frame.size.width - 9, timeSize.height);
//    _workCreateTime.backgroundColor = [UIColor clearColor];
//    _workCreateTime.textColor = [UIColor whiteColor];
////    _workCreateTime.backgroundColor = [UIColor redColor];
//    
//    CGSize priceSize = [self changeWorkNameFrame:_price.text size:CGSizeMake(100, 25) font:_price.font];
//    _price.frame = CGRectMake(_bigImage.left + 5, _bigImage.top + 5, priceSize.width + 5, 20);
//    
//    _view.frame =  CGRectMake(_bigImage.left, _bigImage.top, self.width - 20, _bigImage.height);
//    _playImg.frame = CGRectMake(_bigImage.right + 5, _bigImage.bottom - 25, 25, 25);
//    _playLab.frame = CGRectMake(_playImg.right, _playImg.top, 40, 25);
//    _loveImg.frame = CGRectMake(_playLab.right + 5, _playImg.top, 25, 25);
//    _loveLab.frame = CGRectMake(_loveImg.right, _loveImg.top, 40, 25);
//    _typeLable.frame = CGRectMake(_view.right - 150, _loveLab.top, 140, 25);
}
- (void)leftButtonClick:(UIButton *)sender
{
    _leftBlock();
}
- (void)rightButtonClick:(UIButton *)sender
{
    _rightBlock();
}
-(CGSize)changeWorkNameFrame:(NSString *)workName size:(CGSize)size font:(UIFont *)font
{
    NSMutableDictionary *dic = [NSMutableDictionary dictionaryWithObject:font forKey:NSFontAttributeName];
    CGRect frame = [workName boundingRectWithSize:size options:NSStringDrawingUsesLineFragmentOrigin attributes:dic context:nil];
    return frame.size;
}


- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
